package cn.hdu.liang.strings;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class TestRegularExpression {
    public static void main(String[] args) {
        String[] s = {"abcabcabcdefabc", "abc+", "(abc)+", "(abc){2,}"};
        for(String arg : s) {
            System.out.println(arg);
            Pattern p = Pattern.compile(arg);
            Matcher m = p.matcher(s[0]);
            while(m.find()) {
                System.out.println(m.group() + " at positions " + m.start() + "-" + m.end());
            }
            System.out.println();
        }
    }
}
